home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1995…tember: Reference Library / Dev.CD Sep 95 RL / Dev.CD Sep 95 RL.toast / mac / Technical Documentation / develop / develop Issue 2 code / Speed Development / Graph.h < prev    next >
Encoding:
C/C++ Source or Header  |  1990-03-06  |  2.2 KB  |  61 lines  |  [TEXT/MPS ]

  1. /*------------------------------------------------------------------------------
  2. #
  3. #    Graph.h
  4. #
  5. #    Copyright © 1989-90 Apple Computer, Inc.
  6. #    All rights reserved.
  7. #
  8. #    The includes for the Graph library.
  9. #
  10. -------------------------------------------------------------------------------*/
  11.  
  12. /* These are the kinds of graphs that our library supports, although only the
  13.    bar graph is implemented for this example. */
  14. typedef enum {kBar, kStackedBar, kPie, kLine} GraphType;
  15.  
  16. #define kMaxPoints 20            /* maximum number of points we support */
  17. #define kMargin 10                /* the left/right margin of each bar in bar graph */
  18.  
  19. typedef struct {
  20.     short    whichOne;            /* the index of this point */
  21.     long    value;                /* the value of this point */
  22.     short    top;                /* the graphics rectangle of this point */
  23.     short    left;
  24.     short    bottom;
  25.     short    right;
  26. } GraphValue, *GraphValuePtr;
  27.  
  28. typedef GraphValue GData[kMaxPoints-1];    /* array of graph points, 0-based! */
  29.  
  30. typedef struct {
  31.     GraphType    thisGraph;            /* type of graph it is */
  32.     short    numPoints;                /* number of points in this graph */
  33.     short    top;
  34.     short    left;
  35.     short    bottom;
  36.     short    right;                    /* the graph’s rectangle with respect
  37.                                     to which our graph is computed */
  38.     short    graphYMax;                /* the graph's maximum Y coord value */
  39.     short    graphYMin;                /* the graph's minimum Y coord value */
  40.                                     /* use these to scale the graph. */
  41.     GData    graphItems;                /* the data points in the graph */
  42. } GraphStruct, *GraphStructPtr;
  43.  
  44. /* the function prototypes */
  45. #ifdef __cplusplus
  46. extern "C" {
  47. #endif
  48. GraphStructPtr DoGraphInit( GraphType whichGraphType );
  49. void DoGraphSetGraphRect( short top, short left, short bottom, short right, GraphStructPtr graphStorage );
  50. void DoGraphSetPoint( short which, long value, GraphStructPtr graphStorage );
  51. short DoGraphGetNumPoints( GraphStructPtr graphStorage );
  52. void DoGraphComputeBars( GraphStructPtr graphStorage );
  53. short DoGraphGetYMax( GraphStructPtr graphStorage );
  54. short DoGraphGetYMin( GraphStructPtr graphStorage );
  55. short DoGraphGetBar( short which, short *top, short *left, short *bottom, short *right,
  56.                     GraphStructPtr graphStorage );
  57. GraphStructPtr DoGraphDispose( GraphStructPtr graphStorage );
  58. #ifdef __cplusplus
  59. }
  60. #endif
  61.